/**
 * Copyright (c) 时间, Tal.Ben 袁东昊 (ydonghao2@gmail.com).
 *
 * 版权
 */
package com.talben.soudian.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.talben.soudian.AppManager;
import com.talben.soudian.R;
import com.talben.soudian.ui.imageindicator.ImageIndicatorView;

/**
 * @Title: GuideActivity.java
 * @Package com.talben.soudian.ui
 * @Description: 引导界面
 * @author Tal.Ben
 * @date 2015年5月24日 下午9:35:02
 * @version v1.0
 */
public class GuideActivity extends Activity{

	private ImageIndicatorView imageIndicatorView;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 防止第三方跳转时出现双实例
        Activity aty = AppManager.getActivity(MainActivity.class);
        if (aty != null && !aty.isFinishing()) {
            finish();
        }

        View view = View.inflate(this, R.layout.activity_guide, null);
        setContentView(view);
        
        //实例化共通操作
        imageIndicatorView = (ImageIndicatorView) findViewById(R.id.guide_indicate_view);
		//滑动监听器
		imageIndicatorView.setOnItemChangeListener(new ImageIndicatorView.OnItemChangeListener() {
			@Override
			public void onPosition(int position, int totalCount) {
				if(position== (totalCount-1)){
					UIHelper.gotoStartPage(GuideActivity.this);
					finish();
				}
			}
		});
		final Integer[] resArray = new Integer[] { R.drawable.guide01, R.drawable.guide02, R.drawable.guide03, R.drawable.guide04 };
		imageIndicatorView.setupLayoutByDrawable(resArray);
		imageIndicatorView.setIndicateStyle(ImageIndicatorView.INDICATE_USERGUIDE_STYLE);
		imageIndicatorView.show();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}

